﻿function sendMsg(obj) {
	obj = defaultx(obj, 'username');
	if (refreshWin('sendMsg_' + obj.username)) return;

	var to = new Ext.form.TextField({
				fieldLabel : '收件人',
				name : 'to',
				anchor : '95%',
				allowBlank : false,
				value : obj.username
			});
	var title = new Ext.form.TextField({
				fieldLabel : '主题',
				name : 'title',
				anchor : '95%',
				allowBlank : false,
				value : obj.title
			});
	var content = new Ext.form.HtmlEditor({
				fieldLabel : '内容',
				name : 'content',
				anchor : '95% -55'
			});
	var form = new Ext.FormPanel({
				frame : true,
				labelAlign : 'right',
				labelWidth : 50,
				bodyStyle : 'padding-top:5px',
				items : [to, title, content],
				fbar : new Ext.Toolbar({
							items : [new Ext.Button({
												text : '取消',
												iconCls : 'cancel-icon',
												handler : function() {
													win.close();
												}
											}), new Ext.Button({
												text : '发送',
												iconCls : 'ok-icon',
												handler : onsend
											})]
						})
			});
	var win = new Ext.Window({
				id : 'sendMsg_' + obj.username,
				title : '发送消息' + (obj.username ? ' - ' + obj.username : ''),
				iconCls : 'newmail-icon',				layout : 'fit',
				width : 650,
				height : 350,
				minWidth : 400,
				minHeight : 250,
				items : form
			});
	win.show();

	function onsend() {
		if (!form.getForm().isValid() || !isNoBlank(content)) {
			alertx('请正确输入内容！');
			return;
		}
		ajaxform({
					form : form,
					url : url.sendMsg,
					success : function() {
						alertx('消息发送成功！');
						win.close();
					}
				});
	}
}
